(function($){
	$.ajaxSetup({
		beforeSend:function(){
			$(".loading").show();
		},
		complete:function(){
			$(".loading").hide();
		}
	});
	$.widget("ctrl.list",{
		options:{
			url:'',
			rows:10,
			template:'',
			appendTo:''
			
		},
		_create:function(){
			var _this = this;
			this.event={
				search:function(){
					settings.page = 1;
					try{
						_this.loadData(settings);
					}catch(e){
						e.print();
					}
				},
				pager:{
					init:function(settings){
						$('.pager').empty().hide();
						 if(settings==null)return;
						 var $this = this;
						 if(_this.result.total>_this.options.rows){
							 $('.pager').show().pager({
								pagenumber: $this.getCurrentPage(settings), 
								pagecount: Math.ceil(_this.result.total/_this.options.rows), 
								buttonClickCallback: function(clickedPageNumber){
									settings.page = clickedPageNumber;
									$this.currentPage = clickedPageNumber;
									$this.doPage(settings);
								} 
							});
						 }else{
							 this.currentPage = 1;
						 }
					},
					doPage:function(settings){
						try{
							_this.loadData.call(_this,settings);
						}catch(e){
							e.print();
						}
					},
					getCurrentPage:function(settings){
						return settings.page==null?1:settings.page;
					}
				}
			};
		},
		_init:function(){
			//this.addEventListener();
			this.loadData({});
		},
		addEventListener:function(){
		
		},
		loadData:function(settings){
			var _this = this;
			(function(){
				$.ajax({
                    url:_this.options.url,
                    cache:false,
                    data:$.extend({page:settings.page==null?1:settings.page,rows:_this.options.rows},settings),
					type:'get',
					dataType:'json',
					success:function(result,msg,response){
						_this.result = result;
						_this.render(result);
						_this.event.pager.init(settings);
					}
				});
			})();
		},
		render:function(result){
			if(result.total!=0){
				$(this.options.appendTo).empty().append($(this.options.template).tmpl(result));
			}else{
				$(this.options.appendTo).empty().append('没有搜索到记录');
			}
		}
	});
})(jQuery);
function order_list(){
		$("body").list();
}